support doc creation in qmake. (#609)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Mon, 27 Jul 2020 23:44:14 +0000 (17:44 -0600)
committerGitHub <noreply@github.com>
Mon, 27 Jul 2020 23:44:14 +0000 (17:44 -0600)
* support doc creation in qmake.

pass parameters to tools/mkcapabilites instead of
using text replacement in configure.

text replacement in xmldoc/makedoc was unnecessary, directory
creation is handled in the recipee.

there is some foolishness in GPSBabel.pro to allow overriding of
WEB and DOCVERSION on the command line of make.  If those values
are known when running qmake it could be slightly simpler.

* remove dependency on makedoc.in.

* improve fop comments.

* further update fop comments

GPSBabel.pro
Makefile.in
configure
configure.ac
tools/mkcapabilities [new file with mode: 0755]
tools/mkcapabilities.in [deleted file]
xmldoc/.gitignore
xmldoc/makedoc [new file with mode: 0755]
xmldoc/makedoc.in [deleted file]

index 60c6bc7f533bcfb7876c74e668ddffffea19411b..eab30a4bd07dd7f2bbb7944d9dcad41198967110 100644 (file)
@@ -16,6 +16,7 @@ if(equals(QT_MAJOR_VERSION, $$MIN_QT_VERSION_MAJOR):equals(QT_MINOR_VERSION, $$M
 QT -= gui
 
 TARGET = gpsbabel
+VERSION = 1.7.0
 
 CONFIG += console
 CONFIG -= app_bundle
@@ -262,12 +263,72 @@ linux{
 cppcheck.commands = cppcheck --enable=all --force --config-exclude=zlib --config-exclude=shapelib $(INCPATH) $$ALL_FMTS $$FILTERS $$SUPPORT $$JEEPS
 QMAKE_EXTRA_TARGETS += cppcheck
 
-gpsbabel.pdf.depends = FORCE
-gpsbabel.pdf.commands += perl xmldoc/makedoc &&
+!defined(WEB, var) {
+  WEB = ../babelweb
+}
+!defined(DOCVERSION, var) {
+  DOCVERSION=$${VERSION}
+}
+
+index.html.depends = gpsbabel FORCE
+index.html.commands += web=\$\${WEB:-$${WEB}} &&
+index.html.commands += docversion=\$\${DOCVERSION:-$${DOCVERSION}} &&
+index.html.commands += mkdir -p \$\${web}/htmldoc-\$\${docversion} &&
+index.html.commands += perl xmldoc/makedoc &&
+index.html.commands += xmlwf xmldoc/readme.xml &&  #check for well-formedness
+index.html.commands += xmllint --noout --valid xmldoc/readme.xml &&    #validate
+index.html.commands += xsltproc \
+  --stringparam base.dir "\$\${web}/htmldoc-\$\${docversion}/" \
+  --stringparam root.filename "index" \
+  xmldoc/babelmain.xsl \
+  xmldoc/readme.xml &&
+index.html.commands += tools/fixdoc \$\${web}/htmldoc-\$\${docversion} "GPSBabel \$\${docversion}:" &&
+index.html.commands += tools/mkcapabilities \$\${web} \$\${web}/htmldoc-\$\${docversion}
+QMAKE_EXTRA_TARGETS += index.html
+
+#
+# The gpsbabel.pdf target depends on additional tools.
+# On macOS you can 'brew install fop' to get fop and the hyphenation package.
+# On Debian/Ubuntu you can 'apt-get install fop' to get fop and the hyphenation package.
+# 'fop' must be obtained from your distribution or http://xmlgraphics.apache.org/fop/
+#   0.92beta seems to work OK, BUT.
+#   * If you have a package called 'docbook-xml-website' it's reported
+#     to prevent the build from working.   Remove it. (Suse)
+#   * Sun Java seems to be required.   GCJ 1.4.2 doesn't work.   You can
+#     force Sun Java to be used by creating ~/.foprc with 'rpm_mode=' (Fedora)
+#     Get it from http://www.java.com
+# The Hyphenation package must be obtained from your distribution or
+#   the project site at http://offo.sourceforge.net/ - be sure to get the
+#   version that corresponds to the version of FOP that you used above.
+#
+#
+# The docbook XSL must be 1.71.1 or higher.
+#   * Remember to update /etc/xml/catalogs if you manually update this.
+#
+
+gpsbabel.html.depends = gpsbabel FORCE
+gpsbabel.html.commands += perl xmldoc/makedoc &&
+gpsbabel.html.commands += xsltproc \
+   --output gpsbabel.html \
+   --stringparam toc.section.depth "1" \
+   --stringparam html.cleanup "1" \
+   --stringparam make.clean.html "1" \
+   --stringparam html.valid.html "1" \
+   --stringparam html.stylesheet \
+   "https://www.gpsbabel.org/style3.css" \
+   http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl \
+ xmldoc/readme.xml
+QMAKE_EXTRA_TARGETS += gpsbabel.html
+
+gpsbabel.pdf.depends = gpsbabel FORCE
+gpsbabel.pdf.commands += web=\$\${WEB:-$${WEB}} &&
+gpsbabel.pdf.commands += docversion=\$\${DOCVERSION:-$${DOCVERSION}} &&
+gpsbabel.pdf.commands += perl xmldoc/makedoc && 
 gpsbabel.pdf.commands += xmlwf xmldoc/readme.xml && #check for well-formedness
 gpsbabel.pdf.commands += xmllint --noout --valid xmldoc/readme.xml &&   #validate
 gpsbabel.pdf.commands += xsltproc -o gpsbabel.fo xmldoc/babelpdf.xsl xmldoc/readme.xml &&
-gpsbabel.pdf.commands += HOME=. fop -q -fo gpsbabel.fo -pdf gpsbabel.pdf
-#gpsbabel.pdf.commands += cp gpsbabel.pdf $(WEB)/htmldoc-$(DOCVERSION)/gpsbabel-$(DOCVERSION).pdf
+gpsbabel.pdf.commands += HOME=. fop -q -fo gpsbabel.fo -pdf gpsbabel.pdf &&
+gpsbabel.pdf.commands += mkdir -p \$\${web}/htmldoc-\$\${docversion} &&
+gpsbabel.pdf.commands += cp gpsbabel.pdf \$\${web}/htmldoc-\$\${docversion}/gpsbabel-\$\${docversion}.pdf
 QMAKE_EXTRA_TARGETS += gpsbabel.pdf
 
index 5ace8da1711d0e9731a13ae9f190c28ac1173f4d..cd2e2606f23d20780ddfa0a4b6935cf8f1e71e67 100644 (file)
@@ -158,7 +158,7 @@ gpsbabel$(EXEEXT): configure Makefile $(OBJS) @USB_DEPS@ @GPSBABEL_DEBUG@
 gpsbabel-debug: $(OBJS) @USB_DEPS@
        $(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) @LIBS@ $(QT_LIBS) @USB_LIBS@ $(OUTPUT_SWITCH)$@
 
-Makefile gbversion.h: Makefile.in config.status xmldoc/makedoc.in \
+Makefile gbversion.h: Makefile.in config.status \
          gbversion.h.in gui/setup.iss.in
        CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
@@ -233,7 +233,7 @@ dep:
        echo '  $$(srcdir)/mkstyle.sh > internal_styles.cc || (rm -f internal_styles.cc ; exit 1)'  >> /tmp/dep
        echo Edit Makefile.in and bring in /tmp/dep
 
-$(WEB)/htmldoc-$(DOCVERSION)/index.html: FORCE
+$(WEB)/htmldoc-$(DOCVERSION)/index.html: gpsbabel FORCE
        mkdir -p $(WEB)/htmldoc-$(DOCVERSION)
        perl xmldoc/makedoc
        xmlwf xmldoc/readme.xml         #check for well-formedness
@@ -244,7 +244,7 @@ $(WEB)/htmldoc-$(DOCVERSION)/index.html: FORCE
         xmldoc/babelmain.xsl \
         xmldoc/readme.xml
        tools/fixdoc $(WEB)/htmldoc-$(DOCVERSION) "GPSBabel $(DOCVERSION):"
-       tools/mkcapabilities
+       tools/mkcapabilities $(WEB) $(WEB)/htmldoc-$(DOCVERSION)
 
 #
 # The .fo and PDF versions depend on additional tools.
@@ -261,7 +261,7 @@ $(WEB)/htmldoc-$(DOCVERSION)/index.html: FORCE
 # The docbook XSL must be 1.71.1 or higher.
 #   * Remember to update /etc/xml/catalogs if you manually update this.
 #
-gpsbabel.fo:  FORCE
+gpsbabel.fo: gpsbabel FORCE
        perl xmldoc/makedoc
        xmlwf xmldoc/readme.xml         #check for well-formedness
        xmllint --noout --valid xmldoc/readme.xml       #validate
@@ -269,11 +269,12 @@ gpsbabel.fo:  FORCE
 
 gpsbabel.pdf: gpsbabel.fo
        HOME=. fop -q -fo gpsbabel.fo -pdf gpsbabel.pdf
+       mkdir -p $(WEB)/htmldoc-$(DOCVERSION)
        cp gpsbabel.pdf $(WEB)/htmldoc-$(DOCVERSION)/gpsbabel-$(DOCVERSION).pdf
 
 
-gpsbabel.html: FORCE # gpsbabel
-       perl xmldoc/makedoc
+gpsbabel.html: gpsbabel FORCE
+       perl xmldoc/makedoc
        xsltproc \
          --output $@ \
          --stringparam toc.section.depth "1" \
index 610b837f0550a141b2bb7651dd2692f73a51ddb7..6b9b18f04ef2d7884b601ccc045f286e772cf283 100755 (executable)
--- a/configure
+++ b/configure
@@ -6549,9 +6549,7 @@ as_dir=zlib/contrib/minizip; as_fn_mkdir_p
 as_dir=testo.d; as_fn_mkdir_p
 as_dir=mac/libusb; as_fn_mkdir_p
 
-ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc"
-
-ac_config_files="$ac_config_files tools/mkcapabilities"
+ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -7249,8 +7247,6 @@ do
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "gbversion.h") CONFIG_FILES="$CONFIG_FILES gbversion.h" ;;
     "gui/setup.iss") CONFIG_FILES="$CONFIG_FILES gui/setup.iss" ;;
-    "xmldoc/makedoc") CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;;
-    "tools/mkcapabilities") CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
@@ -7801,11 +7797,6 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;}
 
   esac
 
-
-  case $ac_file$ac_mode in
-    "tools/mkcapabilities":F) chmod +x tools/mkcapabilities ;;
-
-  esac
 done # for ac_tag
 
 
index cdfe3f978f300bad2a33a9f231ac693d52c815b7..f2adfd0aa7ba1e7cf00d45e251857941c8a918eb 100644 (file)
@@ -369,6 +369,5 @@ AS_MKDIR_P([zlib/contrib/minizip])
 AS_MKDIR_P([testo.d])
 AS_MKDIR_P([mac/libusb])
 
-AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc])
-AC_CONFIG_FILES([tools/mkcapabilities], [chmod +x tools/mkcapabilities])
+AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss])
 AC_OUTPUT
diff --git a/tools/mkcapabilities b/tools/mkcapabilities
new file mode 100755 (executable)
index 0000000..63a20eb
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+capabilitiesdir=$1
+htmldocdir=$2
+
+./gpsbabel -^2 | sed 's/\&/\&amp;/' | awk  -F'\t' '
+function getcap(type, cap, sname, lname) {
+       if (type == "internal") return
+       print "<tr>"
+       print "<td class=\"fmtline\">" lname "<br />"
+
+       print "<a href=\"htmldoc-development/fmt_" sname ".html\">" sname "</a></td>"
+       
+       for (i = 1; i <= 6; i++) {
+               c = substr(cap, i, 1)
+               printf "<td class=\"cap\">"
+               if (c != ("-")) printf "yes"
+               printf "</td>\n"
+       }
+       print "</tr>"
+}
+
+getcap($1, $2, $3, $5)
+' > ${capabilitiesdir}/capabilities.inc
+
+FMTS=`./gpsbabel -^2 | grep -v '^internal' | sed 's/\&/\&amp;/' | awk  -F'\t' '{print $3}'`
+for f in $FMTS
+do
+       [ ! -f ${htmldocdir}/fmt_${f}.html ] && echo Missing doc for $f
+done
+
+exit 0
diff --git a/tools/mkcapabilities.in b/tools/mkcapabilities.in
deleted file mode 100644 (file)
index 04dcbc3..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# mkcapabilities.in is used to create mkcapabilities.  
-#
-./gpsbabel -^2 | sed 's/\&/\&amp;/' | awk  -F'\t' '
-function getcap(type, cap, sname, lname) {
-       if (type == "internal") return
-       print "<tr>"
-       print "<td class=\"fmtline\">" lname "<br />"
-
-       print "<a href=\"htmldoc-development/fmt_" sname ".html\">" sname "</a></td>"
-       
-       for (i = 1; i <= 6; i++) {
-               c = substr(cap, i, 1)
-               printf "<td class=\"cap\">"
-               if (c != ("-")) printf "yes"
-               printf "</td>\n"
-       }
-       print "</tr>"
-}
-
-getcap($1, $2, $3, $5)
-' > @DOCDIR@capabilities.inc > @DOCDIR@capabilities.inc
-
-FMTS=`./gpsbabel -^2 | grep -v '^internal' | sed 's/\&/\&amp;/' | awk  -F'\t' '{print $3}'`
-for f in $FMTS
-do
-       [ ! -f @DOCDIR@/htmldoc-@DOCVERSION@/fmt_${f}.html ] && echo Missing doc for $f
-done
-
-exit 0
index f23f1c26223e931bc6f8a6c80548df2bd1c82ce9..ac3c7d7b896d735bb4a6f0ceb32124d997135b66 100644 (file)
@@ -1,2 +1 @@
 /autogen/
-/makedoc
diff --git a/xmldoc/makedoc b/xmldoc/makedoc
new file mode 100755 (executable)
index 0000000..2b8ef3b
--- /dev/null
@@ -0,0 +1,265 @@
+#!/usr/bin/perl
+
+#
+# makedoc.in is used to generate makedoc.   Editing makedoc is a bad idea.
+#
+
+@options;
+
+sub expandrw {
+   my $read = shift;
+   my $write = shift;
+   my $type = shift;
+
+   my $res = "";
+   if ( ($read eq 'r') || ($write eq 'w')) {
+     $res .= "      <listitem>\n        <para role=\"fmtcapsitem\">\n          ";
+     if ( ($read eq 'r') && ($write eq 'w')) {
+       $res .= "read and write $type";
+     }
+     elsif ( $read eq 'r' ) {
+       $res .= "read $type";
+     }
+     elsif ( $write eq 'w' ) {
+       $res .= "write $type";
+     }
+     $res .= "\n        </para>\n      </listitem>\n";
+   }
+   $res;
+}
+
+sub expandoptions {
+   my $opts = shift;
+   my $res = "  <para role=\"fmtcapshdr\">\n    This format can...\n    <itemizedlist>\n";
+
+   $res .= expandrw( substr($opts,0,1), substr($opts,1,1), 'waypoints' );
+   $res .= expandrw( substr($opts,2,1), substr($opts,3,1), 'tracks' );
+   $res .= expandrw( substr($opts,4,1), substr($opts,5,1), 'routes' );
+
+   $res .= "    </itemizedlist></para>\n";
+
+   $res;
+}
+
+sub expandsuboptions {
+  my $f = shift;
+  my $res;
+  $olist = $options{$f};
+
+  # If no options, don't clutter things.
+  if ($olist eq "") { return; }
+
+  # Comma separate the human-readable variation.
+  $olist =~ s/> </>, </g;
+
+  $res .= "<para>This format has the following options: ";
+  $res .= $olist;
+  $res .= ".</para>";
+
+  $res;
+}
+
+
+sub include {
+   my $name=shift;
+   my $dir2=shift;
+
+   $name2 = $name;
+   $name2 =~ s/-/_/g;
+   $d2 = $dir2;
+   $d2 =~ s:/.*::;
+   $name2 = $d2.'_'.$name2;
+   print PARTS qq(<!ENTITY inc_$name2 SYSTEM "../$dir2/$name.xml">\n);
+   print FILE "\&inc_$name2;\n";
+   if (! -e "$dir/$dir2/$name.xml") {
+     open TMP, ">$dir/$dir2/$name.xml";
+     print TMP "\n";
+     close TMP;
+   }
+}
+
+sub includef {
+   my $name=shift;
+
+   $name2 = $name;
+   $name2 =~ s/-/_/g;
+   print PARTS qq(<!ENTITY inc_$name2 SYSTEM "$name.xml">\n);
+   print FORMATS "\&inc_$name2;\n";
+}
+
+
+
+$dir = $0;
+$dir =~ s:/.*$::;
+
+@agdir=`mkdir -p $dir/autogen`;
+open PARTS, ">$dir/autogen/_parts.xml";
+print PARTS qq(<!-- This document is automatically generated. -->\n);
+print PARTS qq(<!ENTITY formats SYSTEM "_formats.xml">\n);
+print PARTS qq(<!ENTITY filters SYSTEM "_filters.xml">\n);
+
+open FORMATS, ">$dir/autogen/_formats.xml";
+print FORMATS qq(<!-- This document is automatically generated. -->\n);
+
+@formats = `./gpsbabel -^3`;
+
+$going = 0;
+$dooptions = 0;
+
+# Prescan the argument list for options.
+
+for (@formats) {
+   chomp;
+   s/\&/\&amp;/g;
+   s/</\&lt;/g;
+   s/>/\&gt;/g;
+   @line = split "\t";
+
+   if (($line[0] eq 'file') || ($line[0] eq 'serial')) {
+       $fmt = $line[2];
+       # Pennance for earlier sins.  Rename magellan -> magellan1 here.
+       if ($line[4] eq "Magellan serial protocol") {
+        $fmt = "magellan1";
+       }
+       $skipping = 0;
+   }
+   if ( $line[0] eq 'internal' || $line[5] eq 'xcsv') {
+       $skipping = 1;
+   }
+   if ($line[0] eq 'option' && $skipping == 0) {
+     $optname = $line[2];
+
+     $options{$fmt} .= "<link linkend=\"fmt_${fmt}_o_${optname}\">$optname</link> ";
+   }
+}
+
+
+for (@formats) {
+   chomp;
+   s/\&/\&amp;/g;
+   s/</\&lt;/g;
+   s/>/\&gt;/g;
+   @line = split "\t";
+
+   if ( $line[0] eq 'internal') {
+     if ($going) {
+       print FILE "</section>\n";
+       close FILE;
+       $going = 0;
+     }
+     if ( $line[5] eq 'xcsv' ) {
+       $line[0] = 'file';
+     }
+   }
+
+   if (($line[0] eq 'file') || ($line[0] eq 'serial')) {
+     if ($going) {
+       print FILE "</section>\n";
+       close FILE;
+     }
+     $id = $line[2];
+     if ( $fmts{$id} ) {
+       $id .= $fmts{$id}++;
+     }
+     else {
+       $fmts{$id} = 1;
+     }
+     includef( 'fmt_'.$id );
+     open FILE, ">$dir/autogen/fmt_$id.xml";
+     print FILE <<END;
+<!-- This document is automatically generated. -->
+<section id="fmt_$id">
+  <title>$line[4] ($line[2])</title>
+END
+     print FILE expandoptions($line[1]);
+     print FILE expandsuboptions($id);
+     $going = 1;
+     $dooptions = 1;
+     if ( defined($line[5]) && ($line[5] ne $line[2]) ) {
+       print FILE <<END;
+<para>
+This format is derived from the <link linkend="fmt_$line[5]">$line[5]</link>
+format, so it has all of the same options as that format.
+</para>
+END
+       if ($line[5] eq 'xcsv' ) {
+         $dooptions=0;
+       }
+     }
+     include($id,"formats");
+   }
+   elsif ($going && $dooptions && ($line[0] eq 'option')) {
+     $nid = 'fmt_'.$id.'_o_'.$line[2];
+     print FILE <<END;
+  <section id="$nid">
+    <title><option>$line[2]</option> option</title>
+    <para>
+      $line[3].
+    </para>
+END
+     include($id.'-'.$line[2],"formats/options");
+     print FILE <<END;
+  </section>
+END
+   }
+}
+
+if ($going) {
+  print FILE "</section>\n";
+  close FILE;
+  $going = 0;
+}
+
+
+open FORMATS, ">$dir/autogen/_filters.xml";
+print FORMATS qq(<!-- This document is automatically generated. -->\n);
+
+@filters = `./gpsbabel -%1`;
+
+$going = 0;
+
+for (@filters) {
+   chomp;
+   s/\&/\&amp;/g;
+   s/</\&lt;/g;
+   s/>/\&gt;/g;
+   @line = split "\t";
+
+   if ($going && ($line[0] eq 'option')) {
+     print FILE <<END;
+  <section id="fmt_$line[1]_o_$line[2]">
+    <title>$line[2] option</title>
+    <para>
+      $line[3].
+    </para>
+END
+     include($line[1].'-'.$line[2],"filters/options");
+     print FILE <<END;
+  </section>
+END
+   }
+   else {
+     if ($going) {
+       print FILE "</section>\n";
+       close FILE;
+     }
+     includef( 'filter_'.$line[0] );
+     open FILE, ">$dir/autogen/filter_$line[0].xml";
+     print FILE <<END;
+<!-- This document is automatically generated. -->
+<section id="filter_$line[0]">
+  <title>$line[1] ($line[0])</title>
+END
+     include($line[0],"filters");
+     $going = $line[0];
+   }
+}
+
+
+if ($going) {
+  print FILE "</section>\n";
+  close FILE;
+  $going = 0;
+}
+close FORMATS;
+close PARTS;
diff --git a/xmldoc/makedoc.in b/xmldoc/makedoc.in
deleted file mode 100755 (executable)
index 61aefc2..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-#!/usr/bin/perl
-
-#
-# makedoc.in is used to generate makedoc.   Editing makedoc is a bad idea.
-#
-
-@options;
-
-sub expandrw {
-   my $read = shift;
-   my $write = shift;
-   my $type = shift;
-
-   my $res = "";
-   if ( ($read eq 'r') || ($write eq 'w')) {
-     $res .= "      <listitem>\n        <para role=\"fmtcapsitem\">\n          ";
-     if ( ($read eq 'r') && ($write eq 'w')) {
-       $res .= "read and write $type";
-     }
-     elsif ( $read eq 'r' ) {
-       $res .= "read $type";
-     }
-     elsif ( $write eq 'w' ) {
-       $res .= "write $type";
-     }
-     $res .= "\n        </para>\n      </listitem>\n";
-   }
-   $res;
-}
-
-sub expandoptions {
-   my $opts = shift;
-   my $res = "  <para role=\"fmtcapshdr\">\n    This format can...\n    <itemizedlist>\n";
-   
-   $res .= expandrw( substr($opts,0,1), substr($opts,1,1), 'waypoints' );
-   $res .= expandrw( substr($opts,2,1), substr($opts,3,1), 'tracks' );
-   $res .= expandrw( substr($opts,4,1), substr($opts,5,1), 'routes' );
-   $res .= "    </itemizedlist></para>\n";
-
-   $res;  
-}
-
-sub expandsuboptions {
-  my $f = shift;
-  my $res;
-  $olist = $options{$f};
-
-  # If no options, don't clutter things.
-  if ($olist eq "") { return; }
-
-  # Comma separate the human-readable variation.
-  $olist =~ s/> </>, </g;
-  $res .= "<para>This format has the following options: ";
-  $res .= $olist;
-  $res .= ".</para>";
-  $res;
-}
-
-
-sub include {
-   my $name=shift;
-   my $dir2=shift;
-
-   $name2 = $name;
-   $name2 =~ s/-/_/g;
-   $d2 = $dir2;
-   $d2 =~ s:/.*::;
-   $name2 = $d2.'_'.$name2;
-   print PARTS qq(<!ENTITY inc_$name2 SYSTEM "../$dir2/$name.xml">\n);
-   print FILE "\&inc_$name2;\n";
-   if (! -e "$dir/$dir2/$name.xml") {
-     open TMP, ">$dir/$dir2/$name.xml";
-     print TMP "\n";
-     close TMP;
-   }
-}
-
-sub includef {
-   my $name=shift;
-
-   $name2 = $name;
-   $name2 =~ s/-/_/g;
-   print PARTS qq(<!ENTITY inc_$name2 SYSTEM "$name.xml">\n);
-   print FORMATS "\&inc_$name2;\n";
-}
-
-
-
-@dir=`mkdir -p @DOCDIR@`;
-$dir = $0;
-$dir =~ s:/.*$::;
-
-@agdir=`mkdir -p $dir/autogen`;
-open PARTS, ">$dir/autogen/_parts.xml";
-print PARTS qq(<!-- This document is automatically generated. -->\n);
-print PARTS qq(<!ENTITY formats SYSTEM "_formats.xml">\n);
-print PARTS qq(<!ENTITY filters SYSTEM "_filters.xml">\n);
-
-open FORMATS, ">$dir/autogen/_formats.xml";
-print FORMATS qq(<!-- This document is automatically generated. -->\n);
-
-@formats = `./gpsbabel -^3`;
-
-$going = 0;
-$dooptions = 0;
-
-# Prescan the argument list for options.
-
-for (@formats) {
-   chomp;
-   s/\&/\&amp;/g;
-   s/</\&lt;/g;
-   s/>/\&gt;/g;
-   @line = split "\t";
-
-   if (($line[0] eq 'file') || ($line[0] eq 'serial')) {
-       $fmt = $line[2];
-       # Pennance for earlier sins.  Rename magellan -> magellan1 here.
-       if ($line[4] eq "Magellan serial protocol") {
-        $fmt = "magellan1";
-       }
-       $skipping = 0;
-   }
-   if ( $line[0] eq 'internal' || $line[5] eq 'xcsv') {
-       $skipping = 1;
-   }
-   if ($line[0] eq 'option' && $skipping == 0) {
-     $optname = $line[2];
-
-     $options{$fmt} .= "<link linkend=\"fmt_${fmt}_o_${optname}\">$optname</link> ";
-   }
-}
-
-
-for (@formats) {
-   chomp;
-   s/\&/\&amp;/g;
-   s/</\&lt;/g;
-   s/>/\&gt;/g;
-   @line = split "\t";
-
-   if ( $line[0] eq 'internal') {
-     if ($going) {
-       print FILE "</section>\n";
-       close FILE;
-       $going = 0;
-     }
-     if ( $line[5] eq 'xcsv' ) {
-       $line[0] = 'file';
-     }
-   }
-
-   if (($line[0] eq 'file') || ($line[0] eq 'serial')) {
-     if ($going) {
-       print FILE "</section>\n";
-       close FILE;
-     }
-     $id = $line[2];
-     if ( $fmts{$id} ) {
-       $id .= $fmts{$id}++;
-     }
-     else {
-       $fmts{$id} = 1;
-     }
-     includef( 'fmt_'.$id );
-     open FILE, ">$dir/autogen/fmt_$id.xml";
-     print FILE <<END;
-<!-- This document is automatically generated. -->
-<section id="fmt_$id">
-  <title>$line[4] ($line[2])</title>
-END
-     print FILE expandoptions($line[1]);
-     print FILE expandsuboptions($id);
-     $going = 1;
-     $dooptions = 1;
-     if ( defined($line[5]) && ($line[5] ne $line[2]) ) {
-       print FILE <<END;
-<para>
-This format is derived from the <link linkend="fmt_$line[5]">$line[5]</link>
-format, so it has all of the same options as that format.
-</para>
-END
-       if ($line[5] eq 'xcsv' ) {
-         $dooptions=0;
-       }
-     }
-     include($id,"formats");
-   }
-   elsif ($going && $dooptions && ($line[0] eq 'option')) {
-     $nid = 'fmt_'.$id.'_o_'.$line[2];
-     print FILE <<END;
-  <section id="$nid">
-    <title><option>$line[2]</option> option</title>
-    <para>
-      $line[3].
-    </para>
-END
-     include($id.'-'.$line[2],"formats/options");
-     print FILE <<END;
-  </section>
-END
-   }
-}
-
-if ($going) {
-  print FILE "</section>\n";
-  close FILE;
-  $going = 0;
-}
-
-
-open FORMATS, ">$dir/autogen/_filters.xml";
-print FORMATS qq(<!-- This document is automatically generated. -->\n);
-
-@filters = `./gpsbabel -%1`;
-
-$going = 0;
-
-for (@filters) {
-   chomp;
-   s/\&/\&amp;/g;
-   s/</\&lt;/g;
-   s/>/\&gt;/g;
-   @line = split "\t";
-
-   if ($going && ($line[0] eq 'option')) {
-     print FILE <<END;
-  <section id="fmt_$line[1]_o_$line[2]">
-    <title>$line[2] option</title>
-    <para>
-      $line[3].
-    </para>
-END
-     include($line[1].'-'.$line[2],"filters/options");
-     print FILE <<END;
-  </section>
-END
-   }
-   else {
-     if ($going) {
-       print FILE "</section>\n";
-       close FILE;
-     }
-     includef( 'filter_'.$line[0] );
-     open FILE, ">$dir/autogen/filter_$line[0].xml";
-     print FILE <<END;
-<!-- This document is automatically generated. -->
-<section id="filter_$line[0]">
-  <title>$line[1] ($line[0])</title>
-END
-     include($line[0],"filters");
-     $going = $line[0];
-   }
-}
-
-
-if ($going) {
-  print FILE "</section>\n";
-  close FILE;
-  $going = 0;
-}
-close FORMATS;
-close PARTS;